<template>
    <div class="page">
        <!-- 导航栏 -->
        <div class="navBar">
            <customNavBar :leftTetx=leftTetx :titleTest=titleTest></customNavBar>
        </div>
        <!-- 页面内容 -->
        <div class="content">
            <van-list class="vanList" v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
                <van-cell class="cells" v-for="(v,c) in listDataCompleted" :key="c">
                    <div class="card" :class="v.reportType == '1' ? 'jbReport' : 'xbReport'">
                        <div class='cardT'>
                            <div class="labelsTop" style="width: 80%;">
                                <!-- <span>[客户{{v.readStatus == 0 ? '未读' : '已读' || '已读'}}]</span> {{v.monManName}}刘青的保单检视报告 -->
                                {{v.monManName}}的保单检视报告
                                <img src="../../assets/img/listReport/yd.png" alt="" v-if="v.readStatus == 1">
                                <img src="../../assets/img/listReport/wd.png" alt=""  v-else>
                            </div>
                            <div class='reportSec'>
                                <div class='reportSecon'>
                                    <div class="reportSeconf">
                                        <div class="labels">
                                            <span class='labelst'>保险机构</span>
                                            <span class="textContent">{{ v.deptName  || '0'}}</span>
                                        </div>
                                        <div class="labels">
                                            <span class='labelst'>保险服务人员</span>
                                            <span class="textContent">{{ v.monManName || '1'}}</span>
                                        </div>
                                    </div>
                                    <div class="reportSeconf">
                                        <div class="labels">
                                            <span class='labelst'>演示期间</span>
                                            <span class="textContent">{{ v.reportParam1  || '0'}}</span>
                                        </div>
                                        <div class="labels">
                                            <span class='labelst'>报告查看期间</span>
                                            <span class="textContent">{{ v.reportStartTime}}至{{ v.reportEndTime || '2023-10-10 至 2024-10' }}</span>
                                        </div>
                                    </div>
                                </div>
                                <img src="../../assets/img/listReport/jt.png" alt="" @click="goDetailedVersion(v)">
                            </div>
                        </div>
                    </div>
                </van-cell>
            </van-list>
        </div>
    </div>
</template>

<script lang="ts" setup name="listReportsx">
import { useRouter, useRoute } from "vue-router"
import { Toast } from '/@/utils/Message';
import { onMounted } from "vue"
import { reactive, ref } from 'vue'
import { sm2 } from 'sm-crypto';
import customNavBar from "/src/components/NavBar/customNavBar.vue"
import { radioGroupProps } from 'vant';
import { json } from 'stream/consumers';
import { selectTaskReportListByConsumer } from "/@/api/auth/index"
//公钥串---加密使用
const publicKey = ref<string>("044291b381a039a8d7d02d7272d2d7c78a30d33e3eeaa0b509bf77d2376582ab2d573730e6bfe9a53bad53f53ac1a85d9c11050931f04bc8b3afc04144d5a6f9be")
const router = useRouter()
const route = useRoute()
const leftTetx = ref("")
const titleTest = ref("报告列表-消费者")

const loading = ref(false)
const finished = ref(false)
const onLoad = () => {
    // 异步更新数据
}
const columns = [
  { text: '10年', value: '0' },
  { text: '20年', value: '1' },
  { text: '30年', value: '2' },
  { text: '终身', value: '3' },
];
// 报告类型 reportType 1简版
// 演示期间 reportParam 
// isExpire 是否过期不能点详情
// isUnlock 是否解锁false展示 解锁祥版
const listDataCompleted = ref([''])
// 加密方法
const JIAMIPublicData=(data:string)=> {
    //publicKey 为sm2的公钥，公钥用来加密，私钥用来解密
    //示例对应的私钥为 74a89d4e78dd999a1882e0202566ee8971464eaf097dede170c86ad683e6e751  用来给后端解密用
    //const publicKey =
    //'0476cf11ef3ab14ac836c0bf850c46cb96402c1d7dd4ded1591a4e5a4fea8951a96a842b4d4e7b9ec6fd779ccc6ef8d83ee7623184e6788847ed0c827351d41093';
    const cipherMode = 1;
    const result = sm2.doEncrypt(data, publicKey.value,cipherMode);
    return `04${result}`;
}
// 从机构系统来这个页面  1.带参数走联合登陆 走的通带参数条页面到本页面
// 2.走不通
const eportList = () => {
    // let a =  {
    //     monManCredType: "111",
    //     monManCredNum: JIAMIPublicData("220182200207027217"),
    //     deptCode : "000002",
    // }
  selectTaskReportListByConsumer({}).then((res: any) => {
        if(res.code == 200) {
            listDataCompleted.value = res.data;
            columns.map((v)=>{
                listDataCompleted.value .map((q:any)=>{
                    if(v.value == q.reportParam){
                        q.reportParam1 = v.text
                    }
                })
            })
        }
    })
}
let goDetailedVersion = (v:any) => {
  router.push({
    path: 'detailedVersion',
        query: {
        taskCode: v.taskCode,
        reportType:v.reportType,
        userType: '05',
        }  
    })
}
onMounted(() => {
    eportList()
})

</script>

<!-- less嵌套设置 -->
<style lang="less" scoped>
.verson {
    z-index: 1;
    font-size: 13px;
    color: #198AFA;
    position: absolute;
}
.page {
    background-color: #F5F7FA;
    // height: 100vh;
    width: 100vw;
    // overflow: hidden;
    .navBar {
        :deep(.van-nav-bar) {
            background-color: white;
        }

        :deep(.van-nav-bar__content) {
            background-color: white;
        }
    }

    .content {
        height: 100%;
        width: 100%;
        padding-top: 68px;
        overflow: hidden;
        box-sizing: border-box;

        .vanList {
            margin-bottom: 20px;
            //background-color: #F5F7FA;


            :deep(.van-cell:after) {
                border: none;
            }

            .cells {
                background-color: #F5F7FA;
                .card {
                    width: 355px;
                    display: flex;
                    text-align: left;
                    border-radius: 10px;
                    // justify-content: center;
                    .cardT {
                        margin-left: 18px;
                    }
                    .labelsTop {
                        display: flex;
                        font-size: 15.3px;
                        color: #222222;
                        font-weight: 600;
                        padding-top: 17px;
                        align-items: center;
                        span {
                            color: #198AFA;
                        }
                        img {
                            width: 55px;
                            height: 18px;
                            margin-left: 7px;
                        }
                    }
                    .reportSec {
                        display: flex;
                        align-items: center;
                        .reportSecon {
                            width: 300px;
                            height: 137px;
                            padding: 17px 0;
                            margin: 17px 0;
                            border-radius: 7px;
                            background: rgba(248,249,250,.9);
                            .reportSeconf {
                                display: flex;
                                .labels {
                                    font-size: 13px;
                                    margin-left: 14px;
                                    span {
                                        display: block;
                                    }
                                    .labelst {
                                        font-size: 13px;
                                        font-weight: 400;
                                        color: #868686;
                                    }
                                    .textContent {
                                        font-size: 13px;
                                        margin-left: 7px;
                                        color: #222222;
                                        font-weight: bold;
                                    }
                                }
                                .labels:first-child{
                                    width: 41%;
                                }
                                .labels:last-child {
                                    width: 59%;
                                }
                            }
                            .reportSeconf:last-child {
                                margin-top: 10px;
                            }
                        }
                        img {
                            width: 13px;
                            height: 13px;
                            margin-left: 7px;
                        }
                    }
                    .vanb {
                        display: flex;
                        cursor: pointer;
                        font-size: 10px;
                        margin-bottom: 17px;
                        div {
                            color: #198AFA;
                            border-radius: 3px;
                            border: 1px solid #198AFA;
                            padding: 0px 7px;
                            background: rgba(25,138,250,0.05)
                        }
                        .vanbt{
                            width: 139px;
                            height: 28px;
                            display: flex;
                            color: #298BF0;
                            align-items: center;
                            background: #F4FAFF;
                            justify-content: center;
                            img {
                                top: -1px;
                                width: 17px;
                                height: 17px;
                                margin-right: 3px;
                                position: relative;
                            }
                        }
                        .vanbm{
                            width: 139px;
                            height: 28px;
                            display: flex;
                            color: #FFFFFF;
                            margin-left: 10px;
                            align-items: center;
                            justify-content: center;
                            background: linear-gradient(360deg, #44A1FD 0%, #2792FC 48%, #298BF0 100%);
                            box-shadow: 0px 2 4px 0px rgba(0,101,204,0.1), 0px 1 2px 0px rgba(144,206,246,0.5);
                            img {
                                top: -1px;
                                width: 17px;
                                height: 17px;
                                margin-right: 3px;
                                position: relative;
                            }
                        }
                    }
                    .vanb1 {
                        margin-bottom: 17px;
                        div {
                            width: 300px;
                            height: 30px;
                            display: flex;
                            color: #198AFA;
                            border-radius: 7px;
                            align-items: center;
                            justify-content: center;
                            border: 1px solid #198AFA;
                            background: rgba(25,138,250,0.05)
                        }
                        img {
                            width: 17px;
                            height: 17px;
                        }
                    }
                }
                .xbReport {
                    background: url(../../assets/img/listReport/bj.png);
                    background-size: 97% 100%;
                    background-repeat: no-repeat;
                }
                .jbReport{
                    background: url(../../assets/img/listReport/bj1.png);
                    background-size: 97% 100%;
                    background-repeat: no-repeat;
                }
            }
        }
   }
}
</style>

